Visual Basic (Declaration) | |
---|---|
<ExtensionAttribute()> Public Overloads Shared Function Include(Of TQuery As ITypedEntityQuery)( _ ByVal query As TQuery, _ ByVal propertyPath As String _ ) As TQuery |
Visual Basic (Usage) | ![]() |
---|---|
Dim query As TQuery Dim propertyPath As String Dim value As TQuery value = EntityQueryExtensions.Include(Of TQuery)(query, propertyPath) |
C# | |
---|---|
[ExtensionAttribute()] public static TQuery Include<TQuery>( TQuery query, string propertyPath ) where TQuery: ITypedEntityQuery |
C++/CLI | |
---|---|
[ExtensionAttribute()] public: static TQuery^ Includegeneric<typename TQuery> ( TQuery^ query, String^ propertyPath ) where TQuery: ITypedEntityQuery |
Parameters
- query
- An EntityQuery
- propertyPath
- Dot-separated list of navigation properties that describe the query path in the graph that should be eagerly fetched.
Type Parameters
- TQuery
Return Value
A new IEntityQuery with the defined query path.C# | ![]() |
---|---|
DomainModelEntityManager mgr = new DomainModelEntityManager(); // Query for some customers, and include their orders and details in query. var query1 = mgr.Customers .Where(c => c.Id < 5) .Include("OrderSummaries.OrderDetails"); foreach (Customer c in query1) { Console.WriteLine("order count = " + c.OrderSummaries.Count); } // Query for orders including details where the customer is in London var query2 = mgr.OrderSummaries.Include("OrderDetails") .Where(c => c.Customer.City == "London"); var results = query2.ToList(); |
The propertyPath may represent a simple or complex navigation. For example, if a Customer type has an Orders navigation property, and the Order type has OrderDetails, you can use a property path of "Orders" to eagerly load orders for any customer queried, and you can use "Orders.OrderDetails" to eagerly load both orders and details for queried customers. Note that the complex property path might not be a valid navigation if a collection is returned, as with "Orders.OrderDetails", but instances of the collection must have the indicated property (e.g., anOrder.OrderDetails). All "parts" in the property path will be pre-loaded into the EntityManager cache when the query is executed.
Multiple "Includes" may be added to a query.
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family